/**
 * 柠檬水找零
 *
 * @USER: Administrator
 * @DATE: 2024/9/15 下午6:07
 * @VERSION: 1.0.0
 */
public class LC860 {
    public static void main(String[] args) {
        int[] bills = new int[]{5,5,5,10,20};
        LC860 lc860 = new LC860();
        System.out.println(lc860.lemonadeChange(bills));
    }
    public boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0;
        for (int bill : bills) {
            if (bill == 5) {
                five++;
            }else if (bill == 10) {
                if (five<=0) {
                    return false;
                }
                five--;
                ten++;
            }else {
                // 20元纸币
                if (five > 0 && ten > 0) {
                    five--;
                    ten--;
                } else if (five >= 3) {
                    five -= 3;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}
